package cn.edu.cque.mall.controller;

import cn.edu.cque.mall.entity.Product;
import cn.edu.cque.mall.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @ClassName IndexController
 * @Description
 * @Author chen
 * @Date 2020/10/11 0011 19:18
 */
@Controller
@RequestMapping
public class IndexController {
    @Autowired
    ProductService productService;

    @RequestMapping("/index")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView();
        List<Product> hotList = productService.findHot();
        List<Product> newsList = productService.findNews();
        modelAndView.addObject("hotList", hotList);
        modelAndView.addObject("newsList", newsList);
        modelAndView.setViewName("/jsp/index");
        return modelAndView;
    }
}
